interface FooItf {
    foo: string;
    name: string;
};

interface BarItf {
    bar: string;
    name: string;
};

// 联合类型--
function sayHi(obj: FooItf | BarItf) {
    console.log(obj);
};

let obj1 = { foo: "foo", name: "嘿嘿" };
let obj2 = { bar: "bar", name: "哈哈" };

sayHi(obj1);
sayHi(obj2);
// 联合类型==

// 交叉类型--
// 现在 sayHi 要求obj参数同时包含 foo 和 bar 的属性，所以再 sayHi 内部，有可能同时访问 obj.foo obj.bar 和 obj.name
function sayHi1(obj: FooItf & BarItf) {
    console.log(obj.foo, obj.bar, obj.name);
};

let obj3 = { foo: "foo", bar: "bar", name: "哈哈" };

sayHi1(obj3);
// 交叉类型==